package com.freejava.unittestrestfulapi.controller;

import com.freejava.unittestrestfulapi.entity.User;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

/**
 * 用于测试的User控制器
 */
@RestController
public class UserController {

    // 只返回一个say hi的字符串
    @GetMapping("/hi")
    public String hi(String username) {
        return "Hey, " + username + "!Fighting!";
    }

    // 添加用户
    @PostMapping("/user")
    public String addUser(@RequestBody User user) {
        return user.toString();
    }
}
